package com.webframe.service.impl;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.webframe.dao.IJdbcDao;
import com.webframe.service.def.ITableOperationService;


/**
 * 类功能描述：
 *
 * Description: 
 */
@Service
public class TableOperationService implements ITableOperationService
{
	@Autowired
	private IJdbcDao jdbcDao;
	
	public void doInsertExecute(String tableName,Map<String,Object> object) throws Exception
	{
		jdbcDao.doInsertExecute(tableName, object);
	}
	
	public void doDeleteExecuteByID(String tableName ,String fkColumnName,String id)
	{
		jdbcDao.doDeleteExecuteByID(tableName, fkColumnName, id);
	}
	public void doDeleteExecuteByID(String tableName ,String id)
	{
		jdbcDao.doDeleteExecuteByID(tableName, id);
	}
	@SuppressWarnings("rawtypes")
	public Map doQueryById(String id,String tableName)
	{
		return jdbcDao.doQueryById(id, tableName);
	}
	@SuppressWarnings("rawtypes")
	public List doQueryBySql(String sql)
	{
		return jdbcDao.doQueryBySql(sql);
	}
	public void doDeleteBySql(String sql)
	{
		jdbcDao.doDeleteBySql(sql);
	}
	public void doUpdateExecuteByID(String tableName,String pkColumnName,String id,Map<String,Object> object) throws SQLException
	{
		jdbcDao.doUpdateExecuteByID(tableName, pkColumnName, id, object);
	}
	public void doUpdateBySql(String sql) throws SQLException
	{
		jdbcDao.doUpdateBySql(sql);
	}

	@SuppressWarnings({
				"rawtypes", "unchecked"})
	public void doInsertExecute(String tableName,
			List li,String pkColumnName) throws Exception {
		
		jdbcDao.doBatchInsertOrUpdate(tableName,li,pkColumnName);
		
		
	}

	/* (non-Javadoc)
	 * @see com.berheley.bi.service.def.TableOperationService#doInsertOrUpdateExecute(java.util.Map)
	 */
	@Override
	public void doInsertOrUpdateExecute(Map<String, Object> object)
			throws Exception
	{
		jdbcDao.doInsertOrUpdate(object);
		
	}

	@SuppressWarnings({
				"rawtypes", "unchecked"})
	@Override
	public void doInsertExecute(String tableName, List li) throws Exception {
		for(int i = 1; i<li.size();i++){
			jdbcDao.doInsertExecute(tableName, (Map)li.get(i));
		}
	}
}
